#include "Gear.h"

bool theVideo::init()
{
	const SDL_VideoInfo *VideoInfo = NULL;

	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
		fprintf(stderr, "Attempt to get video info failed %s\n", SDL_GetError());
	atexit(SDL_Quit);

	VideoInfo = SDL_GetVideoInfo();
	if (VideoInfo == NULL)
	{
		fprintf(stderr, "Attempt to get video info failed %s\n", SDL_GetError());
	}
	atexit(SDL_Quit);

	if(isFullscreen)  
	flags |= SDL_FULLSCREEN;

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);

	if(SDL_SetVideoMode(width, height, bpp, flags) == NULL)
		printf (SDL_GetError());
	
	SDL_WM_SetCaption("Gear v0.1","ex1");
	glViewport (0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
	gluPerspective(45.0, width /height, 0.1, 45.0);
	glMatrixMode(GL_MODELVIEW);
	glClearColor(0.2, 0.2, 0.2, 1.0);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 
	return true;
}


void theVideo::drawIt()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();
	glTranslatef(0.0f, 0.0f, 0.0f);

	glColor3f(0.2f, 0.3f, 0.5f);


	SDL_GL_SwapBuffers();
}
